Skip to content

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 2 | Data Groups#1109

Open
Pretty548 wants to merge 29 commits intoCodeYourFuture:mainfrom
Pretty548:sprint-2
Open

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 2 | Data Groups#1109
Pretty548 wants to merge 29 commits intoCodeYourFuture:mainfrom
Pretty548:sprint-2

Conversation

@Pretty548
Copy link
Copy Markdown

@Pretty548 Pretty548 commented Mar 26, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Fixed parseQueryString implementation and handled edge cases
  • Fixed contains function bug
  • Implemented tally function with validation
  • Fixed calculateMedian to handle invalid inputs

@github-actions

This comment has been minimized.

4 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Pretty548 Pretty548 changed the title Sprint 2 Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 2 | Data Groups Mar 26, 2026
@github-actions

This comment has been minimized.

@Pretty548 Pretty548 marked this pull request as draft March 27, 2026 11:32
@Pretty548 Pretty548 marked this pull request as ready for review March 27, 2026 11:32
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
Comment thread Sprint-2/implement/contains.js Outdated
Comment thread Sprint-2/implement/contains.js Outdated
Comment thread Sprint-2/implement/contains.test.js
Comment thread Sprint-2/implement/querystring.js
Comment thread Sprint-2/implement/tally.js Outdated
Comment on lines +6 to +14
const result = {};

items.forEach((item) => {
if (result[item]) {
result[item]++;
} else {
result[item] = 1;
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the following function call returns the value you expect?

tally(["toString", "toString"]);

Suggestion: Look up an approach to create an empty object with no inherited properties.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I updated the implementation to use Object.create(null) so the result object has no inherited properties. This ensures keys like "toString" are handled correctly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed solution is sound, but did you forget to push your changes to GitHub?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had forgotten, sorry

Comment thread Sprint-2/interpret/invert.js Outdated
Comment on lines +30 to +53
const invert = require("./invert");

test("inverts a simple object", () => {
expect(invert({ a: 1 })).toEqual({ 1: "a" });
});

test("inverts an object with multiple key-value pairs", () => {
expect(invert({ a: 1, b: 2 })).toEqual({
1: "a",
2: "b",
});
});

test("returns empty object when given an empty object", () => {
expect(invert({})).toEqual({});
});

test("handles non-string values as keys in the inverted object", () => {
expect(invert({ a: 1, b: true, c: null })).toEqual({
1: "a",
true: "b",
null: "c",
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be implemented in invert.test.js?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! You're right — these tests should live in invert.test.js. I'll move them there to keep the test structure consistent and separated from implementation.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 28, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 28, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 28, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 28, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also some unanswered questions in interpret/invert.js.

Comment thread Sprint-2/implement/tally.js Outdated
Comment on lines +6 to +14
const result = {};

items.forEach((item) => {
if (result[item]) {
result[item]++;
} else {
result[item] = 1;
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed solution is sound, but did you forget to push your changes to GitHub?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 7, 2026
@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented Apr 7, 2026

Looks good.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants